import request from "./request"

export const createChatRoom = async chatRoomForm =>{
  return await request({
    url:"/chatroom/create",
    method:"POST",
    data:chatRoomForm
  })
}

export const updateChatRoomContent = async (id,content)=>{
  return await request({
    url:"/chatroom/update_content",
    method:"POST",
    data:{
      id,
      content
    }
  })
}

export const findChatRoomContentById = async (id,limit=3,skip=0)=>{
  let ret = await request({
    url:"/chatroom/find_content_by_id",
    methos:"GET",
    data:{
      id,
      skip,
      limit
    }
  })

  if(ret.code == 200){
    return ret.data
  }else{
    console.log(ret);
  }
}

export const findChatRoomWithUserIdAndStaffId = async (userId,staffId)=>{
  return await request({
    url:"/chatroom/find_with_userid_and_staffid",
    method:"GET",
    data:{
      userId,
      staffId
    }
  })
}

export const findChatRoomInfoById = async id =>{
  let ret = await request({
    url:"/chatroom/find_by_id",
    method:"GET",
    data:{
      id
    }
  })

  if(ret.code == 200){
    return ret.data
  }
}